" 模式
" noremap 非递归映射；map 递归映射
" unmap 解绑；mapclear 取消所有绑定

" 设置<leader>按键
let mapleader = "\<Space>"
"session
    set sessionoptions-=curdir        "在session option中去掉curdir
    set sessionoptions+=sesdir        "在session option中加入sesdir
    set viminfo=\"50,'1000,h,f1,rA:,r$TEMP:,r$TMP:,r$TMPDIR:,:500,!,n$VIM/_viminfo

    function! WSession()
        exec "mks! ./session.vim"
        exec "wviminfo ./session.viminfo"
    endfunction
    nnoremap <Leader>ws :call WSession()<CR>

    function! RSession()
        exec "source ./session.vim"
        exec "rviminfo ./session.viminfo"
    endfunction
    nnoremap <Leader>rs :call RSession()<CR>

"设置文件类型为objc
    nnoremap <leader>oc :set filetype=objc<CR>
"设置n/N按键无效
    nmap n <Nop>
    nmap N <Nop>
"in vim run
nnoremap <leader>py :call PRUN()<CR>
func! PRUN()
        exec "w"
        if &filetype == 'sh'
                :!time bash %
        elseif &filetype == 'python'
                exec "!clear"
                exec "!time python3 %"
        endif
endfunc

"R重载vim配置
"局限性有点大，如果遇到R之后依然没有更新配置，尝试重新打开工程
nnoremap <silent> R     :source ~/.config/nvim/init.vim \| echo "reloaded"<cr>

" 设置命令提示 唯一标识 共享剪贴板
    set showcmd
    set encoding=utf-8
    set wildmenu
    set conceallevel=0
    set clipboard=unnamed
    set clipboard+=unnamedplus

"Tab 与宏多次操作冲突,所以换成<C->
    " nn 1 1gt
    " nn 2 2gt
    " nn 3 3gt
    " nn 4 4gt
    " nn 5 5gt
    " nn 6 6gt
    " nn 7 7gt
    " nn 8 8gt
    " nn 9 9gt

"寄存器设置
    vmap p pgvy
    "已把s屏蔽，不能再用，为了更好支持s环绕符号编程
    " nnoremap s "_s
    " vnoremap s "_s

" 保存
    nmap <C-s> :w<cr>

" bufferdelete
    nnoremap <leader>bd :bd<cr>

" 跳列
    " nnoremap  :10l<cr>
" 跳行
    " nnoremap  :10j<cr>
